<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>知果汇</title>
    <link href="__STATIC__/admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="__STATIC__/admin/css/font-awesome.min.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <script src="__STATIC__/admin/js/html5shiv.min.js"></script>
    <script src="__STATIC__/admin/js/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
        body {
            background-color: #ffffff;
        }

        .row {
            margin-left: 0px;
            margin-right: 0px;
        }

        .radio-box {
            display: inline-block;
            width: 64px;
        }

        .formControls {
            padding-right: 50px;
            position: relative;
        }

        .del-comment {
            text-align: right;
            margin-bottom: 0;
        }

        .del-comment a {
            color: #666666;
        }

        .chat-list .chat-element .media-body {
            padding-left: 0px;
        }

        .chat-list .chat-element .media-body .speech-box {
            padding: 0 15px;
            padding-left: 0px;
        }

        .chat-list .chat-element .media-body .speech-box:before {
            border: none;
        }

        .chat-list .chat-element .media-body .speech-box small {
            margin-left: 15px;
        }

        .chat-list .chat-element {
            border-bottom: 1px solid #dcdcdc;
        }

        .chat-list .chat-element a img {
            width: 38px;
            height: 38px;
            margin-right: 10px;
        }

        .chat-list .chat-element {
            margin-bottom: 20px;
        }

        .btn {
            border-radius: 2px;
            -webkit-border-radius: 2px;
            text-transform: capitalize;
            font-size: 14px;
            padding: 7px 14px;
            font-weight: 400;
        }

        .chat-reply {
            margin-left: 80px;
            background-color: #ededed;
        }

        .chat-reply .media-body .margin-b-0 {
            color: #3171b4;
        }

        li {
            list-style: none;
        }
    </style>
</head>
<body>
<article class="page-container">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-body no-padding">
                    <div class="row">
                        <input type="hidden" id="submit">
                        <div class="col-md-8">
                            <div class="chat-room padding-20">
                                <ul class="chat-list list-unstyled"></ul>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div><!--col-md-6-->
    </div>

</article>

<script src="__STATIC__/admin/js/jquery.min.js"></script>
<script src="__STATIC__/admin/js/bootstrap.min.js"></script>
<script src="__STATIC__/admin/js/jasny-bootstrap.min.js"></script>
<script src="__STATIC__/admin/js/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/admin/js/jquery.nanoscroller.min.js"></script>
<script src="__STATIC__/admin/js/metismenu.min.js"></script>
<script src="__STATIC__/admin/js/float-custom.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/layer/layer.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/laypage/laypage.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/laydata/laydate.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/getMyDate.js"></script>

<script type="text/javascript">

    $(function () {
        var url = window.location.href;
        id = url.split("#")[1];
        $("#submit").val(id);
        postfile(id);
    })

    function postfile(id) {

        $.ajax({
            type: 'GET',
            url: "{:url('api/orders/orders_comment_msg')}",
            dataType: 'jsonp',
            jsonp: 'callback',
            data: {id: id},
            success: function (msg) {
                if (msg.code == 200) {
                    $(".chat-list").html('');
                    if (msg.data.length > 0) {
                        var html='';
                        for (var i = 0; i < msg.data.length; i++) {
                            var time = msg.data[i].time;
                            ltime = getMyDate(time * 1000);
                            if(msg.data[i].sheet==1&&msg.data[i].a_id==0&&msg.data[i].type==1) {
                                html += '<li class="clearfix chat-element" id="'+msg.data[i].id+'">';
                                html += '<a href="javascript: void(0);" class="pull-left">';
                                html += '<img src="/Images/head/'+msg.data[i].head_img+'" alt="" class="img-circle"></a>';
                                html += '<div class="media-body "><div class="speech-box">';
                                html += '<strong>'+msg.data[i].username+'</strong><small>'+ltime+'</small>';
                                html += '<p class="margin-b-0">'+msg.data[i].content+'</p>';
                                html += ' <p class="del-comment"><a class="btn" onclick="comment_del(this)" href="#" title="删除"><i class="fa fa-trash-o"></i></a></p>';
                                html += '</div></div></li>';
                            }
                            if(msg.data[i].sheet==1&&msg.data[i].a_id==0&&msg.data[i].type==2) {
                                html += '<li class="clearfix chat-element" id="'+msg.data[i].id+'"><div class="media-body "><div class="speech-box"><small style="margin-left: 48px;">'+ltime+'</small>';
                                html += '<p class="margin-b-0" style="margin-left: 48px;">';
                                html += '<span>[追加评价：]</span>'+msg.data[i].seller_name+'</p>';
                                html += '<p class="del-comment"><a class="btn" onclick="comment_del(this)" href="#" title="删除"><i class="fa fa-trash-o"></i></a></p>';
                                html += '</div></div></li>';
                            }
                            

                        }
						for (var j = 0; j < msg.data.length; j++) {
                                //if(msg.data[j].sheet==2&&msg.data[j].a_id==msg.data[i].id) {
								if(msg.data[j].sheet==2) {
                                    html += '<li class="clearfix chat-element chat-reply" id="'+msg.data[j].id+'"><a href="javascript: void(0);" class="pull-left">';
                                    html += '<img src="/Images/Information/'+msg.data[j].image+'" alt="" class="img-circle"></a>';
                                    html += '<div class="media-body"><div class="speech-box" ><strong>'+msg.data[j].seller_name+'[卖家回复]</strong>';
                                    html += '<small>'+getMyDate(msg.data[j].time * 1000)+'</small>';
                                    html += '<p class="margin-b-0">'+msg.data[j].content+'</p>';
                                    html += '<p class="del-comment"><a class="btn" onclick="comment_del(this)" href="#" title="删除"><i class="fa fa-trash-o"></i></a></p>';
                                    html += '</div></div></li>';
                                }
                            }
                        $('.chat-list').html(html);
                    }else {
                        layer.msg('暂时没有评论哟!', {icon: 5, time: 2000});
                    }
                } else {
                    layer.msg('获取信息不成功!', {icon: 5, time: 2000});
                }
            }
        })
    }


    function comment_del(obj) {
        layer.confirm('确认要删除该评论吗？', function (index) {
            var id = $(obj).parents('li').attr('id');
            //此处请求后台程序，下方是成功后的前台处理……
            $.ajax({
                type: 'get',
                url: "{:url('api/orders/orders_comment_del')}",
                dataType: 'jsonp',
                jsonp: 'callback',
                data: {id: id},
                success: function (msg) {
                    if (msg.code == 200) {
                        var uid = $("#submit").val();
                        postfile(uid)
                        layer.msg('已删除!', {icon: 1, time: 1000});
                    } else {
                        layer.msg('删除失败!', {icon: 5, time: 2000});
                    }
                }
            });
            //$(obj).parents("li").remove();
        })
    }
</script>
</body>
</html>